<?php
/**
* @desc 订制表单处理
* @author kevin.wang
* @date 2015-01-01 12:00:00
**/
class CustomForm extends BaseForm
{
	public $username;
	public $destination;
	public $contant;
	public $person_num;
	public $start_time;
	public $status;
	//表单规则
	public function rules()
	{
		return array(
			array('username, destination, contant, start_time', 'required', 'message'=>'必填字段不能为空'),
			array('person_num', 'numerical', 'message'=>'人数必须为数字'),
			array('status', 'boolean', 'message'=>'状态为布尔值'),
		);
	}
	//写入数据
	public function saveData(){
		$model = new Custom;
		$userInfo = json_decode(Yii::app()->session['userinfo'], true);
		$data = $this->attributes;
		$data['author'] = $userInfo['username'];
		return $model->insertCustom($data);
	}
	//修改数据
	public function editData($id){
		$model = new Custom;
		return $model->editCustom($id, $this->attributes);
	}
}
